mui.init({
	swipeBack:false //右滑关闭功能
});
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready',plusReady,true);
}
function plusReady(){
   document.getElementById("jedw").innerText="万元";
   getQueryData();
   //返回首页
   document.getElementById('home').addEventListener('tap', function() {
	    var h=plus.webview.getWebviewById('mainpage');
	    plus.webview.show(h);
	    mui.fire(h,'tabClick',{tabId:'defaultTab'});
   });
   var dDate = new Date();
   //选择日期
   document.getElementById("btncxqj").addEventListener('tap', function() {
	    //dDate.setFullYear(2014, 7, 16);
	    plus.nativeUI.pickDate(function(e) {
	    	var d = e.date;
	    	var dataa =d.getFullYear() +"" + ((d.getMonth() + 1)<10?"0"+(d.getMonth() + 1):(d.getMonth() + 1) );
	    	document.getElementById("cxqj").innerText=dataa;
	    	getQueryData(dataa)
	    }, function(e) {
	    	//info.innerText = "您没有选择日期";
	    }, {
	    	title: "请选择日期",
	    	date: dDate
	    	});
	});
	mui("#pan_table_div").off("tap","pan_table_tr");      
	mui("#pan_table_div").on('tap','.pan_table_tr',function(){
    	/*if($(this).hasClass("backcolor")){
	        var tds=$(this).find("td");
	        selectxmbh=tds[1].innerText+"-"+tds[2].innerText;
	        mui.openWindow({url:"query_hblrjlrfp.html",id:"query_hblrjlrfp",extras:{selectxmbh:selectxmbh},waiting:{autoShow:false}});
    	}else{*/
    	    /*$(this).addClass("backcolor").siblings("tr").removeClass("backcolor");
		    $(this).siblings("tr").find("td").removeClass("backcolor_font");
	        $(this).find("td").addClass("backcolor_font");*/
    	//}
    });  
}
function getQueryData(selectqj){
	var token = plus.storage.getItem("token");
	if(token==null||token==""){
		return;
	}else{
	   panUtil.ajaxLoding.start();
	   mui.ajax(baseServerAdrr+'/query/getGqzjhz',{
	   data: {
	   		token:token,
	   		qj:selectqj
	   },
	   dataType:'json',//服务器返回json格式数据
	   type:'post',//HTTP请求类型
	   timeout:30000,//超时时间设置为10秒；
	   success:function(data){
		    panUtil.ajaxLoding.stop();
		    document.getElementById("cxqj").innerText=data.lastmonth;
		    if(data.code=='success'){
		    	initTable(data.message);
		    }else{
		    	mui.toast(data.message);
		    }
	   },
	   error:function(xhr,type,errorThrown){
		   //异常处理；
		   panUtil.ajaxLoding.stop();
		   mui.toast('服务器异常登录失败! query_gqzjhz.js');
	   }
	  });
	}
}
function initTable(data){
	var tab = document.getElementById("pan_table");
	tab.innerHTML = "";
	//var th="<tr><th rowspan=\"2\">固定资产类别</th><th rowspan=\"2\">行次</th><th>年初余额</th><th colspan=\"7\">本期累计增加</th><th colspan=\"5\">本期累计减少</th><th>期末余额</th></tr>"+
		//	"<tr><th>原值合计</th><th>增加小计</th><th>弃置费用增加</th><th>在建工程转入</th><th>分类间调整</th><th>从分公司转入</th><th>从子公司转入</th><th>盘盈</th><th>减少合计</th><th>报废</th><th>分类间调整</th><th>转出至分公司</th><th>转出至子公司</th><th>原值合计</th></tr>";
	$('#pan_table').append("<thead><tr><th rowspan=\"2\" width=\"170px\">固定资产类别</th><th rowspan=\"2\">行次</th><th rowspan=\"2\">年初余额</th><th colspan=\"3\">本期增加</th><th colspan=\"2\">本期减少(转出)折旧</th><th rowspan='2'>期末余额</th></tr>"+
	"<tr><th>增加小计</th><th>本期提取折旧</th><th>分类间调整</th><th>减少小计</th><th>分类间调整</th></tr></thead><tbody>");
	var num = 0;
	for(var i=0;i<data.length;i++){
		num = num+1;
		$('#pan_table').append(  //onclick=\"trclick(this.id)\"
			  	 		"<tr align='right' class=\"pan_table_tr \" onclick=\"trclick()\">"+
			  	 		   "<td class=\"pan_table_td_left\">"+data[i].dyzd_sj.replace(new RegExp(' ', 'g'),"&nbsp;")+"</td>"+
			  	 		   "<td >"+num+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].ncye),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].zjxj),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].bqtqzj),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].fljtzzj),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].jsxj),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].fljtzjs),2)+"</td>"+
			  	 		   "<td class=\"pan_table_td_right\">"+panUtil.fmoney(panUtil.ytowy(data[i].qmye),2)+"</td>"+
			  	 		"</tr>");
	}	
	$('#pan_table').append("</tbody>");
	$(document).ready(function () {
		plus.screen.resolutionWidth;
        FixTable("pan_table", 1, plus.screen.resolutionWidth, plus.screen.resolutionHeight-140,2,1);
    });
}

